package com.wanwu.channel.service.strategy.handle;

import com.wanwu.channel.common.util.TrueFalse;
import com.wanwu.channel.service.strategy.domain.ApplyClearanceStrategyResponse;

import java.util.Date;
import java.util.Map;

public class AlipayHandle {

    public static ApplyClearanceStrategyResponse handApplyClearanceReturnMap(Map<String, String> respMap) {
        ApplyClearanceStrategyResponse response = new ApplyClearanceStrategyResponse();
        if (TrueFalse.T.equals(respMap.get("is_success"))) {
            if (TrueFalse.UPPER_SUCCESS.equals(respMap.get("result_code"))) {
                response.setApplyClearanceResultStatus(TrueFalse.UPPER_SUCCESS);
                response.setSuccess(Boolean.TRUE);
                response.setTradeNo(respMap.get("trade_no"));
                response.setDeclareNo(respMap.get("alipay_declare_no"));
                response.setIdentityCheck(respMap.get("identity_check"));
                response.setVerDept(respMap.get("ver_dept"));
                response.setPayCode(respMap.get("pay_code"));
                response.setPayTransactionId(respMap.get("pay_transaction_id"));
                response.setTotalAmount(respMap.get("total_amount"));
                response.setModifyTime(new Date());
            } else {
                response.setApplyClearanceResultStatus(respMap.get("result_code"));
                response.setSuccess(Boolean.TRUE);
                response.setErrorCode(respMap.get("detail_error_code"));
                response.setErrorMsg(respMap.get("detail_error_des"));
            }
        } else {
            response.setSuccess(Boolean.FALSE);
            response.setErrorCode(respMap.get("error"));
            response.setErrorMsg("请求支付宝报关接口失败");
        }
        return response;
    }

//    public static QueryApplyClearanceStrategyResponse handQueryClearanceReturnMap(Map<String, Object> respMap) {
//        respMap.get("")
//    }
}
